#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
string s;
int n, sum;
void solve() {
    cin >> n >> s;
    for (int i = 1; i < n; i++) {
        if (s[i] == s[i - 1]) sum++;
    } cout << (sum <= 1 ? "YES" : "NO") << '\n';
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int _ = 1;
    // std::cin >> _;
    while (_--) {
        solve();
    }
    return 0;
}

